#!/bin/bash
version=$(date -d "8 hour" -u +%y.%m.%d.%H)
cd ~/app-root/data/github-sh/red/
if ! diff -q _redirector.js ~/app-root/runtime/repo/uc脚本/Redirector/_redirector.js; then
cp -f ~/app-root/runtime/repo/uc脚本/Redirector/_redirector.js _redirector.js
cp -f ~/app-root/runtime/repo/uc脚本/Redirector/Redirector（分离版）.uc.js Redirector.uc.js
sed -n '1,19p' Redirector.uc.js >1.txt
sed -e '$s#\];#\{#g' -i 1.txt
sed -n '2,$p' _redirector.js >2.txt
sed -n '20,$p' Redirector.uc.js >3.txt
#sed -i "8a\// @charset         utf-8" 1.txt
cat 1.txt 2.txt ~/app-root/data/github-sh/ad/do/blank.txt 3.txt > ./Redirector.uc.js
sed -i '8c\// @downloadURL     http://git.oschina.net/halflife/list/raw/master/Redirector\.uc\.js' Redirector.uc.js
sed -i "11c\// @version         ${version}" Redirector.uc.js
mv -f Redirector.uc.js ~/app-root/runtime/repo/uc脚本/Redirector/Redirector.uc.js
rm -f 1.txt 2.txt 3.txt 4.txt
~/app-root/data/github-sh/log/log.sh "Redirector.uc.js 更新"
fi